﻿#region File Description
//-----------------------------------------------------------------------------
// MainMenuScreen.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using Microsoft.Xna.Framework;
#endregion

namespace pigs
{
    /// <summary>
    /// The main menu screen is the first thing displayed when the game starts up.
    /// </summary>
    class LevelMenu : MenuScreen
    {
        #region Initialization

        GameSettings settings;

        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public LevelMenu(ScreenManager screen, GameSettings set)
            : base("Levels")
        {
            settings = set;
            
            // Create our menu entries.
            MenuEntry DemoLevelMenuEntry = new MenuEntry("Demo");
            MenuEntry CityLevelMenuEntry = new MenuEntry("Ontario");
            MenuEntry MountainLevelMenuEntry = new MenuEntry("British Columbia");
            MenuEntry PrarieLevelMenuEntry = new MenuEntry("Saskatchewan");
            MenuEntry exitMenuEntry = new MenuEntry("Exit");

            // Hook up menu event handlers.
            DemoLevelMenuEntry.Selected += DemoLevelSelected;
            CityLevelMenuEntry.Selected += CityLevelSelected;
            MountainLevelMenuEntry.Selected += MountainLevelSelected;
            PrarieLevelMenuEntry.Selected += PrarieLevelSelected;
            exitMenuEntry.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(DemoLevelMenuEntry);
            MenuEntries.Add(CityLevelMenuEntry);
            MenuEntries.Add(PrarieLevelMenuEntry);
            MenuEntries.Add(MountainLevelMenuEntry);
            MenuEntries.Add(exitMenuEntry);
        }

        /// <summary>
        /// Event handler for when the Play Game menu entry is selected.
        /// </summary>L
        void DemoLevelSelected(object sender, PlayerIndexEventArgs e)
        {
            LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
               new DemoLevel(settings));
        }

        void CityLevelSelected(object sender, PlayerIndexEventArgs e)
        {
            LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
               new City(settings));
        }

        void PrarieLevelSelected(object sender, PlayerIndexEventArgs e)
        {
            LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
               new Prarie(settings));
        }

        void MountainLevelSelected(object sender, PlayerIndexEventArgs e)
        {
            LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
               new Mountain(settings));
        }
        #endregion
    }
}
